import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class TestAlgorithm {

	private List<Vertex> nodes;
	private List<Edge> edges;

	public static void main (String [] args){
		TestAlgorithm t = new TestAlgorithm();
		t.testExcute();
	}

	public void testExcute() {
		nodes = new ArrayList<Vertex>();
		edges = new ArrayList<Edge>();
		for (int i = 0; i < 52; i++) {
			Vertex location = new Vertex("Node_" + i, "Node_" + i);
			nodes.add(location);
		}

		addLane("0:1", 0, 1, 109);
		addLane("1:0", 1, 0, 109);
		addLane("2:1", 2, 1, 157);
		addLane("1:2", 1, 2, 157);
		addLane("(West) Le Conte Ave", 2, 3, 265);
		addLane("(East) Le Conte Ave", 3, 2, 265);
		addLane("(West) Le Conte Ave", 4, 3, 136);
		addLane("(East) Le Conte Ave", 3, 4, 136);
		addLane("(North) Gayley Ave", 5, 0, 192);
		addLane("(South) Gayley Ave", 0, 5, 192);
		addLane("(North) Broxton Ave", 7, 1, 118);
		addLane("(South) Broxton Ave", 1, 7, 118);
		addLane("(North) Westwood Blvd", 8, 2, 118);
		addLane("(South) Westwood Blvd", 2, 8, 118);
		addLane("(East) Weyburn Ave", 5, 6, 52);
		addLane("(West) Weyburn Ave", 6, 5, 52);
		addLane("(East) Weyburn Ave", 6, 7, 58);
		addLane("(West) Weyburn Ave", 7, 6, 58);
		addLane("7:8", 7, 8, 150);
		addLane("8:7", 8, 7, 150);
		addLane("8:9", 8, 9, 128);
		addLane("9:8", 9, 8, 128);
		addLane("10:9", 10, 9, 128);
		addLane("10:9", 9, 10, 128);
		addLane("11:10", 11, 10, 118);
		addLane("10:11", 10, 11, 118);
		addLane("11:10", 11, 10, 180);
		addLane("10:11", 10, 11, 180);
		addLane("11:4", 11, 4, 275);
		addLane("4:11", 4, 11, 275);
		addLane("5:12", 5, 12, 237);
		addLane("12:5", 12, 5, 237);
		addLane("6:13", 6, 13, 235); // one way direction
		addLane("7:14", 7, 14, 235); // one way direction
		addLane("8:15", 8, 15, 207); 
		addLane("15:8", 15, 8, 207); 
		addLane("12:13", 12, 13, 50); 
		addLane("13:12", 13, 12, 50);
		addLane("13:14", 13, 14, 45); 
		addLane("14:13", 14, 13, 45);
		addLane("14:15", 14, 15, 25); 
		addLane("15:14", 15, 14, 25);
		addLane("15:16", 15, 16, 45); 
		addLane("16:15", 16, 15, 45);
		addLane("9:16", 9, 16, 204); 
		addLane("16:9", 16, 9, 204);
		addLane("10:17", 10, 17, 242); 
		addLane("17:10", 17, 10, 242);
		addLane("16:17", 16, 17, 131); 
		addLane("17:16", 17, 16, 131);
		addLane("11:17", 11, 17, 267); 
		addLane("17:11", 17, 11, 267);
		//52
		// Lets check from location Loc_1 to Loc_10
		Graph graph = new Graph(nodes, edges);
		DijkstraAlgorithm dijkstra = new DijkstraAlgorithm(graph);
		dijkstra.execute(nodes.get(14));
		LinkedList<Vertex> path = dijkstra.getPath(nodes.get(0));
		
		
		for (Vertex vertex : path) {
			System.out.println(vertex);
		}
		
	}

	private void addLane(String laneId, int sourceLocNo, int destLocNo,
			int duration) {
		Edge lane = new Edge(laneId,nodes.get(sourceLocNo), nodes.get(destLocNo), duration );
		edges.add(lane);
	}
}